package logic

import (
	"context"
	"team/models/mysql"

	"team/teamrpc/internal/svc"
	"team/teamrpc/teamrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type TeamAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewTeamAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TeamAddLogic {
	return &TeamAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *TeamAddLogic) TeamAdd(in *teamrpc.TeamAddRequest) (*teamrpc.TeamAddResponse, error) {
	// todo: add your logic here and delete this line

	team := mysql.Team{

		Name:    in.Name,
		Address: in.Address,
		Type:    in.Type,
	}
	mysql.DB.Debug().Create(&team)
	return &teamrpc.TeamAddResponse{
		Id: int64(team.ID),
	}, nil
}
